// +----------------------------------------------------------------------
// | desc: global js
// +----------------------------------------------------------------------
// | Created By 2016-10-14
// +----------------------------------------------------------------------
// | Author: zhangliang 
// +----------------------------------------------------------------------

/**
 *desc:初始化加载
 *@param void;
 *@return void;
 */
$(function(){
  //重置rem,1rem=100px
  wap.changeSize();
  wap.anchor();
});

/**
 *desc:构造函数 
 *@param void;
 *@return void;
 */
function Wap(){};


// 锚点跳转
Wap.prototype.anchor = function(){
  $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
      var $target = $(this.hash);
      $target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        $('html,body').animate({
        scrollTop: targetOffset
        },
        500);
        return false;
      }
    }
  }); 
  /*滚动显示隐藏*/
  $scrollTop=$(document).scrollTop();
  if($scrollTop>300){
    $(".gotop").show();
  }else{
    $(".gotop").hide();
  }
  $(window).scroll(function() {
    $scrollTop=$(document).scrollTop();
    if($scrollTop>300){
      $(".gotop").stop(true,true).fadeIn();
    }else{
      $(".gotop").stop(true,true).fadeOut();
     }
  }); 

}

 /**
 *desc:窗口大小改变执行
 *@param void;
 *@return void;
 */
 Wap.prototype.changeSize=function(){
   //重置rem,1rem=100px
   wap.mobileAnswer();
   $(window).resize(function(){
      wap.mobileAnswer();
   });
 };

 /**
 *desc:重置rem,1rem=100px
 *@param void;
 *@return void;
 */
 Wap.prototype.mobileAnswer=function(){
	 var deviceWidth = document.documentElement.clientWidth;
     if(deviceWidth > 750){
         deviceWidth = 750;
     }
     $("html").css("font-size",deviceWidth / 7.5 + 'px');
 };





/**
 *desc:构造函数实例化
 */
var wap = new Wap();